home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Wipes ƒ / Circle bulge.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-08  |  2.6 KB  |  87 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Circle bulge.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define    startgap            1
  32. #define    gapratio            6
  33. #define    zeropointH            15
  34. #define CorrectTime 3
  35. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  36. #define theWindowWidth (boundsRect.right-boundsRect.left)
  37.  
  38. pascal short CircleBulge(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  39.  
  40. /* This copies ovals that always run from the left of the screen to the right,
  41.    but start really squashed and get geometrically taller.  */
  42.    
  43. pascal short CircleBulge(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  44. {
  45.     Rect        theRect;
  46.     RgnHandle    curregion;
  47.     Point        zeropoint;
  48.     int            cy=theWindowHeight/2;
  49.     int            gap=startgap;
  50.     
  51.     theRect.left=boundsRect.left;
  52.     theRect.right=boundsRect.right;
  53.     theRect.top=boundsRect.top+cy-gap;
  54.     theRect.bottom=boundsRect.top+cy+gap;
  55.         
  56.     curregion=NewRgn();
  57.     zeropoint.v=boundsRect.top;
  58.     zeropoint.h=boundsRect.left+zeropointH;
  59.     do
  60.     {
  61.         StartTiming();
  62.  
  63.         SetEmptyRgn(curregion);
  64.         OpenRgn();
  65.             FrameOval(&theRect);  /* this makes the region for copying */
  66.         CloseRgn(curregion);
  67.  
  68.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  69.                 &boundsRect, &boundsRect, 0, curregion);
  70.  
  71.         theRect.top-=gap;
  72.         theRect.bottom+=gap;     /* make the oval taller */
  73.         gap++;
  74.         gap+=gap/gapratio;       /* make the oval grow faster next time */
  75.         
  76.         TimeCorrection(CorrectTime);
  77.     }
  78.     while (!(PtInRgn(zeropoint, curregion)));    /* quit when we hit zeropoint */
  79.  
  80.     CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  81.             &boundsRect, &boundsRect, 0, 0L);    /* copy the whole screen to end it */
  82.     
  83.     DisposeRgn(curregion);
  84.     
  85.     return 0;
  86. }
  87.